home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 003.dms / 003.adf / TEXT / chapter10.txt < prev    next >
Text File  |  1992-09-02  |  17KB  |  458 lines

  1.  
  2.               The Absolute Beginners Guide To Amos
  3.               -------------------------------------
  4.                          Chapter Ten
  5.                          -----------
  6.  
  7.  
  8. We are now going to take a good look at Bobs.
  9.  
  10. Bob is short for Blitter Object, don`t confuse Bobs with sprites, my advice, 
  11. at this stage at least, is to forget about Sprites, they are a bit harder to
  12. use, but they will have their uses as you may find out in the distant future.
  13.  
  14. A Bob is an object under the users or computers control such as the ship
  15. you fire in Space Invaders or the Gobbler you control in Pacman, Bobs
  16. can also be the enemy Invaders etc.  Bobs in fact can be any moving object
  17. you wish.
  18.  
  19. To start with we will have to either create our own bobs in an art package
  20. like Dpaint or use some existing ones already on disk.  Luckily on this very 
  21. disk in the BOBS drawer we have a bob file called SPACECRAFT.ABK. The ABK by
  22. the way stands for Amos Memory Bank.
  23.  
  24. If you want to create your own bobs then as I mentioned you will have to 
  25. draw them in an art program, save the bobs as an IFF picture, load the IFF
  26. picture into the Amos Sprite Grabber program, cut them out and save them as
  27. an ABK file.  You can then load the ABK file into bank 1 of your program.  
  28. It`s not as complicated as I have just made it sound really.
  29.  
  30. Our first mission then is to load our bobs into a memory bank.  Bank one is
  31. especially reserved as a sprite or bob bank.  By the way you can load other 
  32. files into bank 1 if you do not need bobs or sprites in your program.
  33.  
  34.  
  35. LOAD "DF0:BOBS/SPACECRAFT.ABK"
  36. --------------------------
  37. This will load the ABK file into bank one.  How does Amos know which bank to
  38. load it in? You may ask!  Amos examines the file and sees it is a sprite or 
  39. bob bank file and so loads it into the default bank which as I mentioned 
  40. earlier is bank one.
  41.  
  42. We have our bobs loaded into bank one, the next step is to ready the screen
  43. for printing our bob onto,
  44.  
  45.  
  46. FLASH OFF: CURS OFF: HIDE: PAPER 0: CLS 0
  47. -----------------------------------------
  48. If we didn`t turn FLASH OFF (remember colour number three?) Then any part of
  49. our bob that appeared in colour three may flash,  we do not need the text 
  50. cursor or the mouse for this particular program so we disable these, set the
  51. paper colour to 0 (usually black, depending on the palette) and CLear the 
  52. Screen to colour zero (black) as well.
  53.  
  54.  
  55. GET SPRITE PALETTE
  56. -------------------
  57. NOTE: In Amos pro you can use GET BOB PALETTE but in the original Amos
  58.       it is still called SPRITE, don`t let this confuse you, as they are the
  59.       same, OK?.
  60.  
  61. This takes the colours used by the bobs in bank one and replaces Amos`s
  62. default colours, the simplest way to understand this is to put a REM or a
  63. ` in front of the GET SPRITE PALETTE command, this will stop Amos executing
  64. that line and you will see the effect, a load of garbled colours, this is
  65. because Amos is displaying the bob in the default colours and not the colours
  66. that the bobs were originally drawn in.  Remember this technique of putting
  67. REMs or `s in front of lines, it`s a useful way of debugging programs without
  68. actually deleting lines, useful things those REMs.
  69.  
  70.  
  71. BOB 1,10,100,1
  72. --------------
  73. Blimey! that looks complicated, yes, it looks it but it`s fairly straight
  74. forward really, please make a note of the following because I doubt very
  75. much if you will remember this first time.  I will now break down each part
  76. of the line,
  77.  
  78. BOB 1  
  79. This tells Amos that we wish to use a bob, the 1 is really for our
  80. reference because we can have up to 64 bobs on screen at once and we have to
  81. have a number to refer to each one individually.
  82. It is possible to have more than 64 bobs on screen with some twiddling but a
  83. maximum of 64 is enough for now don`t you think?.
  84.  
  85. 10,100 
  86. Remember the LOCATE 0,10: instruction? This is virtually the same except
  87. now we are using pixels instead of bytes as coordinates, there are eight
  88. pixels to a byte so the range is eight times the width and length of text
  89. coordinates, don`t harp about this at this stage it`s not that vital to 
  90. understand as with a bit of experimenting you will get used to the idea.
  91. So the above line means place the bob at 10 pixels across the screen and 100
  92. pixels down the screen. To recap so far we have,
  93.  
  94. BOB 1, Tell Amos what bob number we are calling this
  95. BOB 1,10,100 Place our bob 1 at 10 across and 100 down on the current screen.
  96.  
  97. The last number ,1, is the actual bob image from the bob bank that we want 
  98. displayed on the screen.  Experiment by changing the last number to see what
  99. different bobs we have stored in the bank.  A better way of viewing bobs is
  100. to load the Sprite_editor from your Amos disk and press L to load a bob bank
  101. and view/edit them from there.
  102.  
  103. CLEAR KEY: WAIT KEY
  104. ------------------  
  105. CLEAR the KEYboard buffer and wait for a key press.
  106.  
  107. LISTBANK
  108. --------
  109. Just there to show you what is in the bank.
  110.  
  111.  
  112. That wasn`t so bad after all, the only confusion may arise from the actual
  113. BOB command itself so I will give you a few examples to make things a little
  114. clearer:
  115.  
  116.  
  117. BOB 1,0,0,1        Place BOB at 0 across 0 down image 1 (top left of screen)
  118.  
  119. BOB 2,10,10,1      Place another copy of image 1 at 10,10
  120.  
  121. BOB 1,10,100,1     Place our bob 1 (the one at top left of screen) at 10,100
  122.                    Amos will automatically erase the old bob 1 at 0,0 for you
  123.  
  124. BOB 2,200,100,2    Place bob 2 (which was at 10,10) to 200,100 but also
  125.                    change its image to the bob in slot 2 of the bank.
  126.                    Amos erases the bob at 10,10.
  127.  
  128.  
  129. I hope that answers a few questions for you.  Here is the complete listing.
  130.  
  131.  
  132. REM EXAMPLE10.Amos
  133. FLASH OFF: CURS OFF: PAPER 0: HIDE: CLS 0
  134. LOAD "DF0:BOBS/SPACECRAFT.ABK"
  135. GET SPRITE PALETTE
  136. BOB 1,10,100,1
  137. CLEAR KEY: WAIT KEY
  138. LISTBANK  
  139.  
  140.  
  141. Please spend a while playing around with EXAMPLE10.Amos as you will learn an
  142. awful lot about bobs, and keep taking down those valuable notes.
  143.  
  144.  
  145. Now placing a bob on screen is fine first time but hardly earth shattering
  146. is it? So to pep things up how about animating the spacecraft a little?
  147. Hmm spacecraft don`t move about a lot in flight except in one direction I
  148. suppose but that blue flame from the engine could be made to look better if
  149. it was animated, let`s do that then, as it happens, in the bob bank, images
  150. one to four are exact copies of the ship with the blue flame just slightly
  151. altered, now if we were to place image two on top of image one quickly
  152. then image three over image two etc. It would appear the flame was moving.
  153. Remember those flicker books years ago? Something like that.  
  154. You will probably suspect this is going to entail a major coding 
  155. session and if we were using almost any other language it would, but with 
  156. good old Amos things are a lot easier.  We will take the listing from 
  157. EXAMPLE10.Amos and add just three lines to achieve our objective, this is the
  158. program in full.
  159.  
  160.  
  161. REM EXAMPLE10_1.Amos
  162. FLASH OFF: CURS OFF: PAPER0: HIDE: CLS 0
  163. LOAD "DF0:BOBS/SPACECRAFT.ABK"
  164. GET SPRITE PALLETE
  165. CHANNEL 1 to BOB 1
  166. BOB 1,10,100,1
  167. ANIM 1,"(1,5)(2,5)(3,5)(4,5)L"
  168. ANIM ON
  169. CLEAR KEY: WAIT KEY
  170. LISTBANK  
  171.  
  172.  
  173. Here follows a breakdown of the three new lines,
  174.  
  175. CHANNEL 1 TO BOB 1
  176. ------------------
  177. This weird looking monster is necessary to tell Amos we are about to do some
  178. ANIMating, you don`t need to understand how it works at the moment but you
  179. need to understand that it is needed to use ANIMations, as this is the first
  180. time in this program that we are to use a CHANNEL we may as well use CHANNEL
  181. 1, and the starting bob we are about to use is bob 1 so we use CHANNEL 1 to
  182. BOB 1.  This command tells Amos to set up an interrupt channel, as you have
  183. probably never heard of interrupts, I will explain briefly.  An Interrupt is
  184. like having two programs running at once, your normal Amos program and let us
  185. say an ANIMation, we set the ANIMation to be interrupt driven (that is what 
  186. CHANNEL does) and this means every 50th of a second Amos will execute the 
  187. ANIMation without slowing down your Amos program.  The beauty of interrupts 
  188. are once you have set them up you can forget all about them and they will 
  189. keep on running unless you tell them to stop.  To prove this, RUN 
  190. EXAMPLE10_1.Amos and press a key to stop the program running, now press 
  191. escape and you will see the ANIMation still running under interrupt in the 
  192. background.
  193.  
  194.  
  195. ANIM 1,"(1,5)(2,5)(3.5)(4,5)L"
  196. ------------------------------
  197. The ANIMation line itself looks very complicated at first so as usual I will
  198. break it down for you,
  199.  
  200. ANIM 1
  201. Tell Amos there is going to be an ANIMation string, as it`s our first ANIM
  202. string we will name it 1.
  203.  
  204. (1,5)
  205. Display bob image number 1 and hold it on screen for 5/50ths of a second.
  206.  
  207. (2,5)
  208. Display bob 2 and hold for 5/50ths
  209.  
  210. (3,5)
  211. bob 3, 5/50ths
  212.  
  213. (4,5)
  214. And lastly display bob 4 for 5/50ths of a second
  215.  
  216. L
  217. The L is short for Loop and this means once Amos has finished displaying 
  218. image 4 for 5/50ths of a second it will start all over again from image 1.
  219.  
  220. Don`t forget you must have all the quotes, commas and brackets exactly as in
  221. the example or you will probably get an error.
  222.  
  223.  
  224. ANIM ON
  225. -------
  226. Nothing will actually happen visually until this instruction has been 
  227. executed it simply sets the ANIMation on it`s way, if we have more than one
  228. ANIMation in the same program ANIM ON would set ALL the ANIMations in motion
  229. So if you didn`t want that you would call each ANIMation string by it`s
  230. number i.e. ANIM ON 1. To turn off an ANIMation we use ANIM OFF or 
  231. ANIM OFF N.  (N being your Anim number)
  232.  
  233. Now I will show you the easiest way to make an ANIMated bob MOVE about the
  234. screen.  The following program will use a space picture as a background 
  235. screen, place a bob just outside the edge of the screen and then MOVE the bob
  236. across the screen the bob will then stop and be blown up with an ANIMated 
  237. explosion and sound effect, the listing is identical in places to 
  238. EXAMPLE10_1.Amos.
  239.  
  240. REM A small space animation
  241.  
  242. FLASH OFF: CURS OFF: PAPER 0: HIDE: CLS 0
  243. DOUBLE BUFFER
  244. LOAD "DF0:BOB/SPACECRAFT.ABK"
  245. LOADIFF "DF0:PICS/SPACE.IFF",0
  246. CHANNEL 1 TO BOB 1
  247. CHANNEL 2 TO BOB 1
  248. BOB 1,-48,20,1
  249. ANIM 1,"(1,5)(2,5)(3,5)(4,5)L"
  250. ANIM 2,"(17,5)(18,5)(19,5)(20,5)(21,5)(22,5)(23,5)(24,5)(25,5)"
  251. ANIM ON 1
  252. MOVE X 1,"(1,1,370)"
  253. MOVE ON
  254. WAIT 300
  255. MOVE OFF
  256. ANIM OFF 1
  257. ANIM ON 2
  258. BOOM
  259. WAIT 25
  260. ANIM OFF:BOB OFF
  261. CLEAR KEY: WAIT KEY
  262.  
  263.  
  264. Looks a right old mess doesn`t it? It is not as complicated as it looks, 
  265. trust me.  I am going to do the breakdown as usual so here we go.
  266.  
  267.  
  268. FLASH OFF: CURS OFF: PAPER 0: HIDE: CLS 0
  269. -----------------------------------------
  270. I shouldn`t need to explain this.
  271.  
  272. DOUBLE BUFFER
  273. -------------
  274. To be honest I didn`t actually need to use this command because we are only
  275. using one bob at a time, but DOUBLE BUFFER, in a nutshell, stops your bobs
  276. from flickering.  I won`t go into the technical side of how it works as that
  277. is irrelevant for now and will probably lead to confusion.  
  278. All you need to know is, if your bobs are flickery then use DOUBLE BUFFER 
  279. at the start of your program.
  280.  
  281. LOAD "DF0:BOBS/SPACECRAFT.ABK"
  282. --------------------------
  283. Load the bobs.
  284.  
  285. LOADIFF "DF0:PICS/SPACE.IFF",0
  286. --------------------------
  287. Load an IFF picture into the current screen, this will be our background
  288. picture.  Apologies for my artwork, I am not an artist.  We covered loading
  289. pictures in a previous chapter so look it up or check your notes if need be.
  290.  
  291. CHANNEL 1 TO BOB 1
  292. ------------------
  293. I fully explained this line in the last listing.
  294.  
  295. CHANNEL 2 TO BOB 1
  296. ------------------
  297. We are assigning another interrupt channel for the explosion, as the 
  298. explosion will overwrite bob 1 we will also use Bob 1 for the explosion, 
  299. remember not to get the bob number and image number confused.
  300.  
  301. BOB 1,-48,20,1
  302. --------------
  303. Places bob 1 (The ship) at coordinates -48 pixels across and 20 pixels down
  304. the screen.  I shall explain the minus coordinate, -48 is 48 pixels off of 
  305. the screen edge so we are placing the ship 48 pixels before the left edge of
  306. the screen which means it is not visible.  I did this so when we start moving
  307. the ship it will appear smoothly from off the screen, a much better effect 
  308. than the ship just appearing from nowhere.
  309.  
  310. ANIM 1,"(1,5)(2,5)(3,5)(4,5)L"
  311. -------------------------------
  312. We covered this exact line in the above example.
  313.  
  314. ANIM 2,"(17,5)(18,5)(19,5)(20,5)(21,5)(22,5)(23,5)(24,5)(25,5)"
  315. --------------------------------------------------------------
  316. This is the explosion animation string.  It works the same as the ANIM 1
  317. line except it uses more and different images.  The explosion animation
  318. starts with image 17 and ends at image 25 the delay between each frame is
  319. 5/50ths of a second.  You could change the delay to a higher number for a
  320. faster animation or a lower number for a slower animation.
  321.  
  322. ANIM ON 1
  323. ---------
  324. This sets the ships engine flame animation into motion.  This time we have
  325. had to tell Amos what ANIM to use (1) because there is more than one ANIM
  326. string set up.  See the ANIM ON line in the last example.
  327.  
  328. MOVE X 1,"(1,1,370)"
  329. --------------------
  330. This is the instruction that brings the whole scene to life.
  331. I will break this one down further so we can dissect it thoroughly.
  332.  
  333. MOVE X 1,
  334. --------- 
  335. This part tells Amos we wish to move a bob horizontally, the 1 is the 
  336. bob number we wish to use.
  337.  
  338. "(1,1,370)"
  339. ----------
  340. This is the mechanics of the MOVE instruction, the first number (1) is the 
  341. speed of the movement in 50ths of a second, 1 is the fastest possible.  
  342. The second (1) is the step count which I have set at one pixel for smooth 
  343. movement and the 370 is the amount of pixels we want the ship to move across
  344. the screen and that is it really.  Please take notes on this as to look at it
  345. without knowing what the numbers represent can lead to confusion.  
  346. Remember (Speed,pixels,distance) or as the manual puts it (Speed,Step,Count)
  347. whatever suits you.
  348.                           
  349. Note: Although I have set the speed of the ships movement to maximum it 
  350. moves across the screen quite slow, this is because I set the step rate at
  351. one pixel for smoothness.  If you want an idea of how fast Amos bobs can be
  352. change the step rate to 4 8 or 16 etc. And you will be amazed.
  353.  
  354. MOVE ON
  355. -------
  356. The previous move instruction just sets up the information for Amos this is
  357. the instruction that sets it all in motion.  The ship will not MOVE until 
  358. Amos gets to this line (Remember the same thing with ANIM?) Our spacecraft
  359. will now start to move across the screen.
  360.  
  361.  
  362. WAIT 300
  363. --------
  364. We know what this does, it tells Amos to wait here and do nothing (apart
  365. from interrupts of course) For six seconds.  The reason I have put this WAIT
  366. here is that the next instructions are for the explosion and I want the 
  367. explosion to occur at the other side of the screen, if we didn`t put this in
  368. WAIT 300 the ship would explode almost immediately, try it and see.
  369.  
  370.  
  371. MOVE OFF
  372. --------
  373. We are now preparing for the explosion, the first thing we want to do is stop
  374. the ship in it`s tracks, this we achieve with MOVE OFF which turns off all
  375. previously set up MOVE strings.  If we had more than one MOVE command in the
  376. program we would use MOVE OFF N if we only wanted one of the MOVE strings to
  377. be halted.
  378.  
  379. ANIM OFF 1
  380. ----------
  381. Turn off the engine flame animation.
  382.  
  383. ANIM ON 2
  384. ---------
  385. Start the explosion, ANIM 2.
  386.  
  387. BOOM
  388. ----
  389. While the explosion is in progress play the BOOM sound effect.
  390.  
  391. WAIT 25
  392. -------
  393. WAIT for the explosion to finish.
  394.  
  395. ANIM OFF: BOB OFF
  396. ----------------
  397. Switch all ANIMations OFF and clear the bob from the screen.
  398.  
  399. CLEAR KEY: WAIT KEY
  400. -------------------
  401. Look it up.
  402.  
  403.  
  404. NOTE: This is the simplest way I could find of doing this short Animation
  405.       but there are much better (more complicated) ways.
  406.  
  407.  
  408. -------------------------------------------------------------------------
  409.  
  410. I am afraid that is just the tip of the iceberg as far as bobs, movement
  411. and animation are concerned, it isn`t this tutorials intention to cover
  412. everything but I hope to get you off to a good start and understand the
  413. basics of it.  Here are a few more commands that you will need to know about 
  414. if you delve further into bobs.
  415.  
  416.  
  417. MOVE y
  418. --------
  419. This works identically to MOVE X, the difference of course is MOVE Y moves
  420. the bob vertically along the screen. A minus value would move up the screen
  421. and a positive value down the screen.
  422.  
  423.  
  424. WAIT VBL
  425. --------
  426. This causes Amos to WAIT for a Vertical BLank.  It basically WAITs for Amos
  427. to update the screen which normally happens every 50th of a second, 
  428. if you have a problem with a bob not appearing try a WAIT VBL instruction 
  429. before the BOB command.
  430.  
  431.  
  432. MOVE FREEZE N
  433. -------------
  434. Temporarily stop bobs in their tracks, use MOVE ON N to restart.  
  435. N is optional.
  436.  
  437.  
  438. ANIM FREEZE N
  439. -------------
  440. As above but affects ANIM.
  441.  
  442.  
  443.  
  444. Well that`s quite a lot to take in, make those notes and mess with 
  445. EXAMPLE10.Amos, EXAMPLE10_1.AMOS and EXAMPLE10_2.Amos
  446. Have fun.
  447.  
  448.  
  449. NOTE: The bob file SPACECRAFT.ABK was borrowed from the Amos Extras disk and
  450.       is located in the AMOS SPRITE_600 folder on that disk along with lots
  451.       of other useful bobs.
  452.       The Tracker mod is P.D (author unknown).  
  453.       The background picture I managed myself, sorry.
  454.  
  455.  
  456. End of chapter ten.
  457.  
  458.